﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;

public partial class Admin_Admin_ShopReviewManage : Admin, IRequiresSessionState
{
    private Shop_Review _review;
    public string m_QuickSearchName = "";
    public string m_DetailSearchType = "";
    public string m_DetailSearchName = "";
    public string m_BeginTime = "";
    public string m_EndTime = "";
    public bool m_tag = true;
    public string m_WhereStr = "";
    public string m_LinkHead = "";
    private ArrayList al = new ArrayList();
    private IDbDataParameter[] param;
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected Shop_Review m_review
    {
        get
        {
            Shop_Review review;
            if (this._review == null)
            {
                this._review = new Shop_Review(this.conn);
                review = this._review;
            }
            else
            {
                review = this._review;
            }
            return review;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(23))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Review");
            base.WriteRightErrMsg();
        }
        this.TxtBeginDate.Attributes.Add("onfocus", "SelectDate(" + this.TxtBeginDate.UniqueID + ",'yyyy-MM-dd');");
        this.TxtEndDate.Attributes.Add("onfocus", "SelectDate(" + this.TxtEndDate.UniqueID + ",'yyyy-MM-dd');");
        this.SelectDate.Attributes.Add("onClick", "showsearchdate();");
        if (!base.IsPostBack)
        {
            this.BandPages();
        }
    }
    protected void SetDBParam()
    {
        if (this.al.Count > 0)
        {
            this.param = new IDbDataParameter[this.al.Count];
            this.al.CopyTo(this.param, 0);
        }
    }
    protected void QuickSearch_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.m_tag = false;
        this.BandPages();
    }
    protected void DetailSearchButton_Click(object sender, EventArgs e)
    {
        this.m_tag = false;
        this.BandPages();
    }
    public void QuestString()
    {
        this.m_QuickSearchName = Fetch.Get("QSN");
        if (this.m_QuickSearchName != string.Empty && this.m_tag)
        {
            this.QuickSearch.SelectedValue = this.m_QuickSearchName;
        }
        else
        {
            this.m_QuickSearchName = this.QuickSearch.SelectedValue;
        }
        if (this.m_QuickSearchName != "all")
        {
            string text = this.m_QuickSearchName;
            switch (text)
            {
                case "today":
                    this.m_WhereStr += "and DateDiff(dd,ReviewDate,GetDate())=0 ";
                    goto IL_288;
                case "week":
                    this.m_WhereStr += "and ReviewDate>dateadd(day,-7,GetDate()) ";
                    goto IL_288;
                case "legal":
                    this.m_WhereStr += "and ReviewStatus=1 ";
                    goto IL_288;
                case "illegal":
                    this.m_WhereStr += "and ReviewStatus=0 ";
                    goto IL_288;
                case "salergood":
                    this.m_WhereStr += "and ReviewStar=1 AND TransSize=1 ";
                    goto IL_288;
                case "salercom":
                    this.m_WhereStr += "and ReviewStar=0 AND TransSize=1 ";
                    goto IL_288;
                case "salerbad":
                    this.m_WhereStr += "and ReviewStar=-1 AND TransSize=1 ";
                    goto IL_288;
                case "buyergood":
                    this.m_WhereStr += "and ReviewStar=1 AND TransSize=0 ";
                    goto IL_288;
                case "buyercom":
                    this.m_WhereStr += "and ReviewStar=0 AND TransSize=0 ";
                    goto IL_288;
                case "buyerbad":
                    this.m_WhereStr += "and ReviewStar=-1 AND TransSize=0 ";
                    goto IL_288;
            }
            this.m_WhereStr = "";
        IL_288:
            this.m_LinkHead = this.m_LinkHead + "&QSN=" + this.m_QuickSearchName;
        }
        this.m_DetailSearchType = Fetch.Get("DST");
        if (this.m_DetailSearchType != string.Empty && this.m_tag)
        {
            this.DetailSearchType.SelectedValue = this.m_DetailSearchType;
        }
        else
        {
            this.m_DetailSearchType = this.DetailSearchType.SelectedValue;
        }
        if (this.m_DetailSearchType != string.Empty)
        {
            this.m_DetailSearchName = Fetch.Get("DSN");
            if (this.m_DetailSearchName != string.Empty && this.m_tag)
            {
                this.DetailSearchText.Text = this.m_DetailSearchName;
            }
            else
            {
                this.m_DetailSearchName = this.DetailSearchText.Text.Trim();
            }
            if (this.m_DetailSearchName != string.Empty)
            {
                string text = this.m_DetailSearchType;
                if (text != null)
                {
                    if (!(text == "reviewer"))
                    {
                        if (!(text == "review_to"))
                        {
                            if (!(text == "title"))
                            {
                                if (text == "content")
                                {
                                    this.m_WhereStr += "and ReviewContent like '%'+ @ReviewContent +'%' ";
                                    IDbDataParameter value = this.conn.CreateParameter("@ReviewContent", DbType.String, this.m_DetailSearchName);
                                    this.al.Add(value);
                                }
                            }
                            else
                            {
                                this.m_WhereStr += "and ReviewTitle like '%'+ @ReviewTitle +'%' ";
                                IDbDataParameter value = this.conn.CreateParameter("@ReviewTitle", DbType.String, this.m_DetailSearchName);
                                this.al.Add(value);
                            }
                        }
                        else
                        {
                            this.m_WhereStr += "and ReviewerName like '%'+ @ReviewerName +'%' ";
                            IDbDataParameter value = this.conn.CreateParameter("@ReviewerName", DbType.String, this.m_DetailSearchName);
                            this.al.Add(value);
                        }
                    }
                    else
                    {
                        this.m_WhereStr += "and UserName like '%'+ @UserName +'%' ";
                        IDbDataParameter value = this.conn.CreateParameter("@UserName", DbType.String, this.m_DetailSearchName);
                        this.al.Add(value);
                    }
                }
                string linkHead = this.m_LinkHead;
                this.m_LinkHead = string.Concat(new string[]
				{
					linkHead,
					"&DST=",
					this.m_DetailSearchType,
					"&DSN=",
					base.Server.UrlEncode(this.m_DetailSearchName)
				});
            }
        }
        this.m_BeginTime = Fetch.Get("BT");
        if (this.m_BeginTime != string.Empty && this.m_tag)
        {
            this.TxtBeginDate.Text = this.m_BeginTime;
        }
        else
        {
            this.m_BeginTime = this.TxtBeginDate.Text;
        }
        if (this.m_BeginTime != "")
        {
            this.m_WhereStr += "and [ReviewDate]>@ReviewDate ";
            IDbDataParameter value = this.conn.CreateParameter("@ReviewDate", DbType.DateTime, this.m_BeginTime);
            this.al.Add(value);
            this.m_LinkHead = this.m_LinkHead + "&BT=" + this.m_BeginTime;
        }
        this.m_EndTime = Fetch.Get("ET");
        if (this.m_EndTime != string.Empty && this.m_tag)
        {
            this.TxtEndDate.Text = this.m_EndTime;
        }
        else
        {
            this.m_EndTime = this.TxtEndDate.Text;
        }
        if (this.m_EndTime != "")
        {
            if (this.m_BeginTime != string.Empty)
            {
                if (Convert.ToDateTime(this.m_EndTime) < Convert.ToDateTime(this.m_BeginTime))
                {
                    this.WriteErrMsg("", Language.GetAdminMsg("Common/DateTimeErr"), "");
                }
            }
            this.m_WhereStr += "and [ReviewDate]<@ReviewDateand ";
            IDbDataParameter value = this.conn.CreateParameter("@ReviewDateand", DbType.DateTime, this.m_EndTime);
            this.al.Add(value);
            this.m_LinkHead = this.m_LinkHead + "&ET=" + this.m_EndTime;
        }
        if (this.m_WhereStr != "")
        {
            this.m_WhereStr = "and" + this.m_WhereStr;
            this.m_WhereStr = this.m_WhereStr.Replace("andand", "Where");
        }
        this.SetDBParam();
    }
    protected void BandPages()
    {
        int num = Fetch.GetID("page");
        if (num <= 0)
        {
            num = 1;
        }
        this.QuestString();
        int maxperpage = 15;
        if (this.GridView1.PageSize != 0)
        {
            maxperpage = int.Parse(this.GridView1.PageSize.ToString());
        }
        if (this.param == null)
        {
            this.GridView1.DataSource = this.m_review.GetAllReviews(num, maxperpage, this.m_WhereStr, "");
        }
        else
        {
            this.GridView1.DataSource = this.m_review.GetAllReviews(num, maxperpage, this.m_WhereStr, "", this.param);
        }
        this.GridView1.DataBind();
        this.PagePanel.Text = this.m_review.GetPagePanel(this.m_LinkHead);
    }
    protected void ReviewButton_OnCommon(object sender, CommandEventArgs e)
    {
        bool flag = false;
        string text = e.CommandName.ToString();
        if (text != null)
        {
            if (!(text == "delete_substract"))
            {
                if (!(text == "delete"))
                {
                    if (!(text == "illegal"))
                    {
                        if (text == "legal")
                        {
                            if (base.admin.CheckAdminPower(23))
                            {
                                flag = true;
                            }
                        }
                    }
                    else
                    {
                        if (base.admin.CheckAdminPower(23))
                        {
                            flag = true;
                        }
                    }
                }
                else
                {
                    if (base.admin.CheckAdminPower(23))
                    {
                        flag = true;
                    }
                }
            }
            else
            {
                if (base.admin.CheckAdminPower(23) && base.admin.CheckAdminPower(23))
                {
                    flag = true;
                }
            }
        }
        if (!flag)
        {
            base.WriteRightErrMsg();
        }
        string text2 = this.CheckNumList(base.Request["chk_select"]);
        if (text2 != string.Empty)
        {
            this.m_review.AdminReview(text2, e.CommandName);
        }
        this.m_tag = false;
        this.BandPages();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
    }
}
